use Test::More 'no_plan';

use lib "../lib/cpp", "../lib/ioc", "../lib/toolkit", '../lib/message';

use TinyMessage;
use Signature;
use CClass;
use CHeaderParser;
use CProject;
use CConstructorMatcher;
use CCodeGenerator;
use FindBin;

use IProject;
use IModule;
use IProvider;
use ICreator;

use TestHelper;

my $source = "$FindBin::Bin/cpp/test-ioc-1/";
my $out = $source . "generated";

my $iproject = new IProject();
$iproject->load(new CProject($source));

my @modules = @{ $iproject->modules() };

is (@modules, 1);

my $providers = [
	new IProvider( 
		class_sig('LogService', []),  
		class_sig('ConsoleLogService', []), 
		'getLogSeriviceSingleton', 's',
		class_sig('SINGLETON< ConsoleLogService >', []) ),
	new IProvider( 
		class_sig('LogService', []),  
		class_sig('ConsoleLogService', []), 
		'getLogSeriviceDirect', 'd',
		class_sig('DIRECT< ConsoleLogService >', []) ),
	new IProvider(
		class_sig('LogService', []),  
		class_sig('ConsoleLogServiceProvider', []), 
		'getLogSeriviceCustom', 'c',
		class_sig('ConsoleLogServiceProvider', []))
		 
];
		
my $module = $modules[0];

is(stringfy($module->class()), 'ConsoleLogModule');

is_deeply($module->includes_rel($out), ["../source/modules/ConsoleLogModule.h", 
"../source/modules/ConsoleLogServiceProvider.h", 
"../source/services/ConsoleLogService.h"]);

is_deeply($module->providers(), $providers);

CCodeGenerator::generate($module, $out);

my ($outFile, $realFile) = ($out . "/ConsoleLogModule.cpp", $out . "/ConsoleLogModule.real");
isSame($outFile, $realFile);


